package com.ruoyi.controller.jpjs.capital;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.service.jpjs.capital.CapitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 劳资填报
 * @date 2021/4/9 10:43
 */
@Controller
@RequestMapping("/capitalManage")
public class capitalController extends BaseController {

    @Autowired
    CapitalService capitalService;

    private String prefix = "jpjs/capital";

    @GetMapping()
    public String capital(ModelMap mmap) {
        return prefix + "/capital";
    }

    @PostMapping("/list")
    @ResponseBody
    public List<Map> list(@RequestParam Map map) {
        List<Map> proList = capitalService.selectProList(map);
        return proList;
    }

    /**
     * 跳转添加项目页面
     *
     * @param mmap
     * @return
     */
    @GetMapping("/toAddPro")
    public String toAddPro(ModelMap mmap) {
        return prefix + "/addpro";
    }

    /**
     * 新增项目
     *
     * @param map
     * @return
     */
    @RequestMapping("/proAdd")
    @ResponseBody
    public AjaxResult proAdd(@RequestParam Map map) {
        return toAjax(capitalService.proAdd(map));
    }

    /**
     * 跳转添加工种页面
     *
     * @param typeId
     * @param mmap
     * @return
     */
    @GetMapping("/toAddWork")
    public String toAddWork(String typeId, ModelMap mmap) {
        mmap.put("typeId", typeId);
        return prefix + "/addwork";
    }

    /**
     * 新增工种项目
     *
     * @param map
     * @return
     */
    @RequestMapping("/workAdd")
    @ResponseBody
    public AjaxResult workAdd(@RequestParam Map map) {
        return toAjax(capitalService.workAdd(map));
    }

    /**
     * 跳转添加施工部位页面
     *
     * @param typeId
     * @param mmap
     * @return
     */
    @GetMapping("/toAddPosition")
    public String toAddPosition(String typeId, ModelMap mmap) {
        mmap.put("typeId", typeId);
        return prefix + "/addposition";
    }

    /**
     * 新增施工部位项目
     *
     * @param map
     * @return
     */
    @RequestMapping("/positionAdd")
    @ResponseBody
    public AjaxResult positionAdd(@RequestParam Map map) {
        return toAjax(capitalService.positionAdd(map));
    }

    @RequestMapping("/remove/{id}")
    @ResponseBody
    public AjaxResult remove(@PathVariable("id") String id) {
        return toAjax(capitalService.remove(id));
    }

}
